﻿<phone:PhoneApplicationPage x:Class="DepSoft.Mobile.WP7.FollwIt.MainPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                            xmlns:cimbalino="clr-namespace:Cimbalino.Phone.Toolkit.Behaviors;assembly=Cimbalino.Phone.Toolkit"
                            xmlns:wp7contribcontrols="clr-namespace:WP7Contrib.View.Controls;assembly=WP7Contrib.View.Controls"
                            xmlns:wp7contribcontrolbehaviors="clr-namespace:WP7Contrib.View.Controls.Behaviors;assembly=WP7Contrib.View.Controls"
                            xmlns:gsextra="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP71"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:DepSoftFollwItFramework="clr-namespace:DepSoft.Mobile.WP7.FollwIt.Framework"
                            FontFamily="{StaticResource PhoneFontFamilyNormal}"
                            FontSize="{StaticResource PhoneFontSizeNormal}"
                            Foreground="{StaticResource PhoneForegroundBrush}"
                            SupportedOrientations="Portrait"
                            Orientation="Portrait"
                            mc:Ignorable="d"
                            d:DesignWidth="480"
                            d:DesignHeight="696"
                            shell:SystemTray.IsVisible="True"
                            DataContext="{Binding MainViewModel, Source={StaticResource Locator}}">

    <toolkit:TransitionService.NavigationInTransition>
        <toolkit:NavigationInTransition>
            <toolkit:NavigationInTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardIn"/>
            </toolkit:NavigationInTransition.Backward>
            <toolkit:NavigationInTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardIn"/>
            </toolkit:NavigationInTransition.Forward>
        </toolkit:NavigationInTransition>
    </toolkit:TransitionService.NavigationInTransition>
    <toolkit:TransitionService.NavigationOutTransition>
        <toolkit:NavigationOutTransition>
            <toolkit:NavigationOutTransition.Backward>
                <toolkit:TurnstileTransition Mode="BackwardOut"/>
            </toolkit:NavigationOutTransition.Backward>
            <toolkit:NavigationOutTransition.Forward>
                <toolkit:TurnstileTransition Mode="ForwardOut"/>
            </toolkit:NavigationOutTransition.Forward>
        </toolkit:NavigationOutTransition>
    </toolkit:TransitionService.NavigationOutTransition>

    <interactivity:Interaction.Triggers>
        <interactivity:EventTrigger EventName="Loaded">
            <gsextra:EventToCommand Command="{Binding ViewLoadedCommand}"
                                    PassEventArgsToCommand="True"
                                    IsEnabled="{Binding ViewLoadedCommandEnabled}">
            </gsextra:EventToCommand>
        </interactivity:EventTrigger>
    </interactivity:Interaction.Triggers>

    <!-- DepSoftFollwItFramework:ImageExtension.Source="{Binding Cover}" -->
    <phone:PhoneApplicationPage.Resources>        
        <ItemsPanelTemplate x:Key="ItemsPanelTemplate">
            <toolkit:WrapPanel/>
        </ItemsPanelTemplate>                      
    </phone:PhoneApplicationPage.Resources>

    <shell:SystemTray.ProgressIndicator>
        <shell:ProgressIndicator x:Name="progressOverlay"
                                 IsIndeterminate="{Binding ProgressIndicatorVisible}"
                                 IsVisible="{Binding ProgressIndicatorVisible}" />
    </shell:SystemTray.ProgressIndicator>

    <!--LayoutRoot contains the root grid where all other page content is placed-->
    <!--<Grid x:Name="LayoutRoot" Background="Transparent">-->
    <Grid x:Name="LayoutRoot" Background="{StaticResource PageBackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <interactivity:Interaction.Behaviors>
            <cimbalino:ApplicationBarBehavior IsVisible="{Binding AppBarVisible}" BackgroundColor="#DFDFDF" ForegroundColor="Black">
                <cimbalino:ApplicationBarIconButton Command="{Binding RefreshCommand, Mode=OneTime}"
                                                    IconUri="/icons/appbar.refresh.rest.png"
                                                    Text="refresh"
                                                    IsVisible="true" />
                <!--<cimbalino:ApplicationBarIconButton Command="{Binding UserProfileCommand, Mode=OneTime}"
                                                    IconUri="/icons/appbar.feature.settings.rest.png"
                                                    Text="profile"
                                                    IsVisible="false" />-->
                <cimbalino:ApplicationBarIconButton Command="{Binding UserProfileCommand, Mode=OneTime}"
                                                    IconUri="/icons/appbar.user.png"
                                                    Text="profile"
                                                    IsVisible="true" />                
                <cimbalino:ApplicationBarIconButton Command="{Binding PreviousCommand, Mode=OneTime}"
                                                    IconUri="/icons/appbar.back.rest.png"
                                                    Text="previous"
                                                    IsVisible="{Binding PagingAppBarVisible}"
                                                    Click="appbarButton_Click" />
                <cimbalino:ApplicationBarIconButton Command="{Binding NextCommand, Mode=OneTime}"
                                                    IconUri="/icons/appbar.next.rest.png"
                                                    Text="next"
                                                    IsVisible="{Binding PagingAppBarVisible}"
                                                    Click="appbarButton_Click" />
                <cimbalino:ApplicationBarBehavior.MenuItems>
                    <cimbalino:ApplicationBarMenuItem Command="{Binding AboutCommand, Mode=OneTime}" Text="about" />
                </cimbalino:ApplicationBarBehavior.MenuItems>                
            </cimbalino:ApplicationBarBehavior>
        </interactivity:Interaction.Behaviors>

        <Image HorizontalAlignment="Right" VerticalAlignment="Top" Source="/ApplicationIcon.png" Width="62"/>

        <!--Pivot Control-->
        <controls:Pivot x:Name="MainPagePivot"
                        Title="{Binding ApplicationTitle}"
                        Grid.Row="0"
                        Margin="0,0,0,0"
                        >
            <interactivity:Interaction.Triggers>
                <interactivity:EventTrigger EventName="SelectionChanged">
                    <gsextra:EventToCommand Command="{Binding SelectPivotCommand}" PassEventArgsToCommand="True" />
                </interactivity:EventTrigger>
            </interactivity:Interaction.Triggers>

            <controls:PivotItem Header="{Binding MenuPageName}" Name="MenuPivotItem">
                <Grid x:Name="MenuPivotGrid">
                    <ListBox x:Name="MenuListBox"
                             Margin="12,0,0,0"
                             ScrollViewer.VerticalScrollBarVisibility="Disabled"
                             SelectedItem="{Binding SelectedMenu, Mode=TwoWay}"
                             ItemsSource="{Binding MenuCollection}" ItemTemplate="{StaticResource MenuDataTemplate}"
                             toolkit:TiltEffect.IsTiltEnabled="True" ItemContainerStyle="{StaticResource MenuListBoxItemStyle}">                        
                    </ListBox>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem Header="{Binding StreamPageName}" Name="StreamPivotItem">
                <Grid x:Name="StreamPivotGrid">
                    <ListBox x:Name="StreamListBox"
                             ItemsSource="{Binding Path=StreamCollection}"
                             ItemTemplate="{StaticResource StreamItemTemplate}"
                             SelectedItem="{Binding SelectedStreamItem, Mode=TwoWay}"
                             Margin="12,0,0,0"
                             Height="545"                             
                             toolkit:TiltEffect.IsTiltEnabled="True"                             
                             >
                    </ListBox>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem Header="{Binding MoviePageName}" Name="MoviePivotItem">
                <Grid x:Name="MoviePivotGrid">
                    <ListBox x:Name="MovieListBox"
                             ItemTemplate="{StaticResource MovieItemTemplate}"
                             ItemsSource="{Binding Path=MovieCollection}"
                             ItemsPanel="{StaticResource ItemsPanelTemplate}"
                             Margin="9,-3,0,0"
                             Height="545"
                             Visibility="{Binding CollectionVisible}">
                    </ListBox>
                </Grid>
            </controls:PivotItem>
            <controls:PivotItem Header="{Binding TVPageName}" Name="TVShowPivotItem">
                <Grid x:Name="TVShowPivotGrid">
                    <ListBox x:Name="TVShowListBox"
                             ItemTemplate="{StaticResource TVShowItemTemplate}"
                             ItemsSource="{Binding Path=TVShowCollection}"
                             ItemsPanel="{StaticResource ItemsPanelTemplate}"
                             Margin="9,-3,0,0"
                             Height="545"
                             Visibility="{Binding CollectionVisible}">
                    </ListBox>
                </Grid>
            </controls:PivotItem>            
            <!--<controls:PivotItem Header="{Binding SettingsPageName}" Name="SettingsPivotItem">
                <Grid x:Name="SettingsPivotGrid">
                    <TextBlock Text="{Binding UserNameText}" Style="{StaticResource PhoneTextNormalStyle}" />
                    <TextBox Height="72"
                             HorizontalAlignment="Left"
                             Name="txtUserName"
                             VerticalAlignment="Top"
                             Width="456"
                             Margin="0,22,0,0"
                             Text="{Binding UserName, Mode=TwoWay}"
                     />
                    <TextBlock Text="{Binding PasswordText}" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,100,0,0" />
                    <PasswordBox Height="72"
                                 HorizontalAlignment="Left"
                                 Margin="0,122,0,0"
                                 Name="txtPassword"
                                 VerticalAlignment="Top"
                                 Width="456"
                                 Password="{Binding Password, Mode=TwoWay}"
                     />
                    <Button Content="{Binding ButtonText}"
                            Height="72"
                            Margin="0,201,0,0"
                            x:Name="btnSave"
                            VerticalAlignment="Top"
                            Command="{Binding SaveCommand}" Click="btnSave_Click" />
                </Grid>
            </controls:PivotItem>-->
        </controls:Pivot>
    </Grid>

    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True"
                              IsMenuEnabled="True">
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>